<!DOCTYPE html>
<html lang="zh">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Vue.directive</title>
  <script src="../assets/js/vue.js"></script>
</head>

<body>
  <h1>Vue.directive 自定义指令</h1>
  <hr>
  <div id="app">
    <div v-sunday="color">{{num}}</div>
    <p>
      <button @click="add">ADD</button>
    </p>
  </div>
  <script type="text/javascript">
    Vue.directive("sunday", function (el, binding) {
      console.log(el);
      console.log(binding);
      el.style = 'color:' + binding.value;
    })
    var app = new Vue({
      el: '#app',
      data: {
        num: 0,
        color: 'red'
      },
      methods: {
        add: function () {
          this.num++;
        }
      }
    })
  </script>
</body>

</html>